package angry.courses.servlets;

import javax.naming.InitialContext;

import java.util.List;

import angry.courses.beans.RegisterBean;
import angry.courses.beans.Register;
import angry.courses.entities.CourseEntity;
import angry.courses.entities.StudentEntity;

public class RegisterDelegate {
	
	private Register registerBean;
  
	public RegisterDelegate() {
		try {
			InitialContext ctx = new InitialContext();
			registerBean = (Register) ctx.lookup("angry.courses.beans.RegisterBean");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public CourseEntity getCourse(String name) {
		return registerBean.getCourse(name);
	}
	
	public StudentEntity createStudent(String name, String regNr, int year) {
		return registerBean.createStudent(name, regNr, year);
	}
	
	public void register(CourseEntity course, StudentEntity student) {
		registerBean.register(course, student);
	}
	
	public List<String> getCourseNamesForStudent(StudentEntity student, int sem) {
		return registerBean.getCourseNamesForStudent(student, sem);
	}
	
	public void deleteCoursesForStudent(StudentEntity student) {
		registerBean.deleteCoursesForStudent(student);
	}
	
	public void deleteRelationsForCourse(CourseEntity course) {
		registerBean.deleteRelationsForCourse(course);
	}
	
	public void modifyStudent(StudentEntity student) {
		registerBean.modifyStudent(student);
	}
}
